#ifndef __BALL_H__
#define __BALL_H__

#include <math.h>
#include <stdlib.h>
#include <GL/glut.h>

#include "Settings.h"
#include "Color.h"
#include "CoordF.h"
#include "Drawable.h"
#include "Updatable.h"
#include "TimedEvent.h"
#include "Timer.h"

/*
 * Classe: Ball
 *  Herda de: Drawable, Updatable, TimedEvent
 *
 *   Bola
 *
*/

class Ball : public Drawable, public Updatable, public TimedEvent
{
      private:
              GLfloat fRad, fAccel;
              int ballColor, ballState, ballResolution;
              
              enum ballStates { LOADED, TRAVELLING, IDLE, DYING };
              enum ballEvents { ANIMATION_TIMEOUT };
      public:
             Ball();
             Ball(CoordF pos, CoordF dir, int color = Color::WHITE, GLfloat speed = 0.0);
             ~Ball();

             void setSize(GLfloat newRadius) { fRad = newRadius; }
             GLfloat getSize() { return fRad; }
             
             void setRes(int res) { ballResolution = res; }
             int getRes() { return ballResolution; }

             void setColor(int c) { mMat.setMaterial(c); ballColor = c; }
             int getColor() { return ballColor; }

             void draw();
             void update(double dt);
             void shoot ( CoordF dir, GLfloat pow );

             void disable ();

             void reflectInY();
             void reflectInX();
             void reflectInZ();
             void reflectInXY();
             void reflectInXZ();
             void reflectInYZ();
             
             bool isTravelling() { return (ballState == Ball::TRAVELLING); }
             
             void notifyDestroyed();
             void notifyDetached();
             
             void triggerEvent(int e);
};

#endif
